<template>
    <div class="VIP">
        <van-nav-bar style="background-color: #bfe4f3;"
        title="会员"
        left-arrow 
        @click-left="onClickLeft"/>
        <div class="top_box">
            <h2 class="title1">会员享更多超值优惠</h2>
            <span class="title2">还可享人气作家签名书籍</span>
        </div>
        <div class="card">
            <div class="floatbox">
                <div class="img">
                    <img src="" alt="">
                </div>
                <span class="content1">书友张三</span>
                <span class="content2">开通会员享万本好书</span>
                <div class="price">5元/月</div>
                <div class="tag">
                    <div class="tag1">
                        <div class="icon">
                            <van-icon name="good-job" size="20" color="#bfe4f3" />
                        </div>
                        <div style="font-size: 12px; color: #c9c9c9;">好书推荐</div>
                    </div>
                    <div class="tag1">
                        <div class="icon">
                            <van-icon name="hot" size="20" color="#bfe4f3" />
                        </div>
                        <div style="font-size: 12px; color: #c9c9c9;">万本免费</div>
                    </div>
                    <div class="tag2">
                        <div class="icon">
                            <van-icon name="point-gift" size="20" color="#bfe4f3" />
                        </div>
                        <div style="font-size: 12px; color: #c9c9c9;">定制礼包</div>
                    </div>
                </div>
            </div>    
        </div>
        <div class="goodbooks">
            <div class="rubbish"></div>
            <h4>会员好书</h4>
        </div>
        <div class="books">
            <book-item v-for="item in books" :key="item.id" :books="item"></book-item>
        </div>
        <div class="null"></div> 
        <div class="goodbooks">
            <div class="rubbish"></div>
            <h4>会员活动</h4>
        </div>
        <div>
            <img class="vip-img" src="../../../img/vip-img.png">
            <img class="vip-img2" src="../../../img/vip-img2.png">
        </div>

        <div class="goodbooks">
            <div class="rubbish"></div>
            <h4>会员限免</h4>
            <van-icon class="icon-flush" name="replay" />
            <span class="flush">换一批</span>
        </div>
        <div class="books2">
            <book-item v-for="item in books2" :key="item.id" :books="item"></book-item>
        </div>
        
        <div class="goodbooks">
            <div class="rubbish"></div>
            <h4>男生免费</h4>
        </div>
        <div class="books">
            <book-item v-for="item in books" :key="item.id" :books="item"></book-item>
        </div>
        <div class="null"></div>
        <div class="goodbooks">
            <div class="rubbish"></div>
            <h4>男生免费</h4>
        </div>
        <div class="books">
            <book-item v-for="item in books" :key="item.id" :books="item"></book-item>
        </div>
    </div>
    
</template>

<script>
import bookItem from '@/components/bookItem';
import { getBooksApi } from '@/api/booksApi';
    export default {
        data() {
            return {
                books: [],
                books2: [],
            }
        },
        async created() {
            this.$root.$children[0].$children[1].isShowHead = false;
            let books = await getBooksApi()
            this.books = books.slice(0,3)
            this.books2 = books.slice(4,10)
        },
        beforeDestroy() {
            this.$root.$children[0].$children[1].isShowHead = true;
        },
        methods: {
            onClickLeft(){
                this.$router.push('city_boys');
            }
        },
        components: {
            bookItem,
        },
    }
</script>

<style lang="scss" scoped>
.VIP{
    width: 100%;
}
.card{
    position: relative;
    height: 100px;
}
.top_box{
    width: 100%;
    height: 125px;
    background-color: #bfe4f3;
    border: 1px solid #bfe4f3;
    border-radius: 0 0 25px 25px;
}
.title1{
    margin-top: 10px;
    font-size: 24px;
    color: white;
    margin-left: 20px;
}
.title2{
     font-size: 14px;
     color: white;
     margin-left: 20px;
}
.floatbox{
    width: 350px;
    height: 131px;
    position: absolute;
    background-color: #fff;
    top: -40px;
    left: 12px;
    border-radius: 10px 10px 0 0;
    box-shadow: 0px 0px 6px rgba(153, 153, 153, 0.349019607843137);
    .img{
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background-color: #ccc;
        margin-top: 15px;
        margin-left: 15px;
        float: left;
    }
    .content1{
        width: 70px;
        color: #333;
        font-size: 16px;
        margin-top: 20px;
        margin-left: 70px;
        display: block;
    }
    .content2{
        width: 110px;
        color: #ccc;
        font-size: 12px;
        margin-top: 3px;
        margin-left: 70px;
        display: block;
    }
    .price{
        width: 72px;
        height: 30px;
        background-color: #ff6666;
        border-radius: 25px;
        float:right;
        position: absolute;
        top: 20px;
        right: 10px;
        color: #fff;
        text-align: center;
        line-height: 30px;
        font-size: 13px;
    }
    .tag{
        width: 100%;
        height: 40px;
        margin-top: 10px;
        background-color: #fff;
        display: flex;
        justify-content: space-around
    }
    .tag1{
        width: 115px;
        float: left;
        text-align: center;
        border-right: 1px solid #ccc;
    }
    .tag2{
        width: 115px;
        float: left;
        text-align: center;
    }
    .icon{
        margin: 5px auto;
    }
}
.goodbooks{
   width: 100%;
   height: 54px;
}
.goodbooks>h4{
    font-size: 16px;
    font-weight: 400;
    line-height: 54px;
    float: left;
}
.rubbish{
    width: 3px;
    height: 16px;
    background-color: #2bb283;
    float: left;
    margin-top: 19px;
    margin-left: 12px;
    margin-right: 5px;
}
.flush{
    width: 42px;
    height: 18px;
    float: right;
    font-size: 14px;
    margin-top: 15px;
    margin-right: 5px;
}
.icon-flush{
    width: 16px;
    height: 16px;
    float: right;
    margin-top: 17px;
    margin-right: 20px;
}
.books{
    width: 100%;
    height: 220px;
}
.books2{
    width: 100%;
    height: 400px;
}
.null{
    width: 100%;
    height: 12px;
    background-color: #f2f2f2;
}
.vip-img{
    width: 173px;
    height: 68px;
    border-radius: 5px;
    margin-left: 10px;
}
.vip-img2{
    width: 173px;
    height: 68px;
    border-radius: 5px;
    margin-left: 5px;
}

</style>